// 顶点属性：位置、颜色、纹理坐标
attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;

uniform mat4 u_projTrans;
uniform float u_time;
uniform float u_plantBottomY;
uniform float u_plantHeight;
uniform float u_k;
uniform float u_x0;
uniform float u_texCoordBottomY;
uniform vec2 u_uvSize;
uniform float u_uvV2;
uniform float u_base_height;
uniform float u_swingIntensity;

// 传递给片段着色器的变量
varying float v_time;
varying vec4 v_position;
varying vec4 v_color;
varying vec2 v_texCoords;
varying float v_plantBottomY;
varying vec2 v_uvSize;
varying float v_uvV2;
varying float v_base_height;
varying float v_swingIntensity;

void main() {
    //定义植被参数
    float unitScale = 3.0;
    vec4 position = a_position;
    float wave = cos(u_time);
    float diff = 16.0 - u_plantHeight;

    //高度因子计算
    //v_plantHeightFactor = (position.y - u_plantBottomY) / 16.0;

    //植物摆动
    if (position.y > u_plantBottomY + 6144126.4)
        position.x += wave * unitScale;

//    //version1
//    float curVectorUVY = 1 - a_texCoord0.y;
//    float curRegionBottomUVY = u_texCoordBottomY;
//    float texCoordYFactor = curVectorUVY - curRegionBottomUVY;
//    if (texCoordYFactor > 0.05) {
//        position.y += 16 * unitScale * 1;
//    }

    //version2
    float curVectorUVY = 1.0 - a_texCoord0.y;
    //float curRegionBottomUVY = u_texCoordBottomY;
    //float texCoordYFactor = curVectorUVY - curRegionBottomUVY;
    //蘑菇数据测试
//    if (curVectorUVY == 0.75) {//确定第一个curVectorUVY的值: 确定==0.75
//        position.y += 16.0 * unitScale * 1.0;
//    }
//    if (curVectorUVY == 0.5) {//确定第二个curVectorUVY的值: 确定 == 0.5
//       position.y -= 16.0 * unitScale * 1.0;
//    }
//    if (curRegionBottomUVY == 1) {//确定curRegionBottomUVY的值: 确定 == 0
//        position.y += 16.0 * unitScale * 1.0;
//    }
	//坐标定位id测试
	float gridSize = 16.0 * unitScale;
    //if (position.x == gridSize*1.0) {//确定蓝菇x
    //if (position.x == gridSize*1.0 || position.x == gridSize*3.0) {//
        //position.y += gridSize * 1.0;
    //}

    //position.y += gridSize * curRegionBottomUVY;
    //position.y += gridSize * u_texCoordBottomY;
//    position.y += gridSize * u_uvSize.x;

    gl_Position = u_projTrans * position;

    // 传递到片段着色器
    v_time = u_time;
    v_position = a_position;
    v_color = a_color;
    v_texCoords = a_texCoord0;
    v_plantBottomY = u_plantBottomY;
    v_uvSize = u_uvSize;
    v_uvV2 = u_uvV2;
    v_base_height = u_base_height;
    v_swingIntensity = u_swingIntensity;
}
